import modules from './modules'
import Vue from 'vue'
import Router from '@/plugin/uni-simple-router/index.js'
import {ACCESS_TOKEN} from '@/common/util/constants.js'

Vue.use(Router)
//初始化
const router = new Router({
	encodeURI:false,  
    routes: [...modules]//路由表
});

const whiteList = ['/pages/login/login','/pages/index/index']  //白名单
//全局路由前置守卫
router.beforeEach((to, from, next) => {
	console.log(to,to.meta.title)
	let token=uni.getStorageSync(ACCESS_TOKEN);
	console.log(token)
	next()
	// if(token){
	// 	console.log('33333333333333333333333')
	// 	 next()
	// }else{
	// 	if (whiteList.indexOf(to.path) !== -1) {
	// 		console.log('1111111112')
	// 	  next()
	// 	}else{
	// 		console.log('2222222222222222221111')
	// 	  next({ path: '/pages/login/login'})
	// 	}
	// } 
})
// 全局路由后置守卫
router.afterEach((to, from) => {
	// console.log(to,from)
})
export default router;